/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.struts.controleur;

import com.myapp.struts.modele.Etudiant;
import com.myapp.struts.modele.QueryBD;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.DynaProperty;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Izii Tom's
 */
public class AppelChoixAction extends Action {
    
    private Hashtable<String, String> resultats;
     private ArrayList<HashMap<String, Object>> resulta;
    
     /**
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
       
        AppelChoixForm f = (AppelChoixForm) form;
        HttpSession session = request.getSession();
        QueryBD qb = (QueryBD) session.getAttribute("bd");
        
        
        if(qb.creerCours(f.getDate(), f.getHeureDebut(), f.getHeureFin(), f.getMatiere(), qb.getEnseignant().getNenseingant())){
            session.setAttribute("bd", qb);
            return mapping.findForward("appel");
        }
        else{
            return mapping.findForward("enseignant");
        }
        
        
    }
}
